/**
 * @description profile controller
 * @author chengpeng
 */

const {
    SuccessModel,
    ErrorModel
} = require('../model/ResModel')
const {
    getBlogListByUser
} = require('../services/blog')
const {
    PAGE_SIZE
} = require('../config/constant')

/**
 * @description 个人主页微博列表
 * @author chengpeng
 * @param {string} userName 用户名
 * @param {number} pageIndex 当前页
 */
async function getProfileBlogList(userName, pageIndex = 0) {
    const result = await getBlogListByUser({
        userName,
        pageIndex,
        pageSize: PAGE_SIZE
    })

    const blogList = result.blogList

    return new SuccessModel({
        isEmpty: blogList.length === 0,
        blogList,
        pageSize: PAGE_SIZE,
        pageIndex,
        count: result.count
    })
}

module.exports = {
    getProfileBlogList
}